<template>
  <!-- goodslist -->
  <div class="goodlist">
    <div
      class="listItem"
      v-for="(item) in goodlist"
      :key="item.id"
      @click="getinfo('/home/goodsinfo',item.id)"
    >
      <header>
        <img
          :src="item.img_url"
          alt=""
        >
        <h1 class="title">{{item.title}}</h1>
      </header>
      <div class="price">
        <span class="new">{{item.sell_price}}</span>
        <span class="old">{{item.market_price}}</span>
      </div>
      <div class="des">
        <span>热卖中</span>
        <span>剩余{{item.stock_quantity}}件</span>
      </div>
    </div>
  </div>

</template>
<script>
export default {
  data: () => ({
    page: 1,
    pagesize: 3,
    goodlist: []
  }),
  created() {
    this.getgoods()
  },
  methods: {
    async getgoods() {
      try {
        const { data: { message } } = await this.Api.getgoods(this.page, this.pagesize)
        console.log(message)
        this.goodlist = message
      } catch (error) {
        console.log('请求失败')
      }
    }
  }
}
</script>
<style lang="less" scoped>
img{
  width: 50%;
}
</style>
